<template>
  <div>
    <Panel title="建筑能耗信息" width="380px">
      <div class="info">
        <div class="info-item">
          <div class="title">
            <Icon name="map-filling" :size="30" color="rgba(255, 255, 255, 0.4)"></Icon>
            <div>建筑内用水量</div>
          </div>
          <div class="content">
            <div class="value">545466</div>
            <div class="unit">吨</div>
          </div>
        </div>
        <div class="info-item">
          <div class="title">
            <Icon name="map-filling" :size="30" color="rgba(255, 255, 255, 0.4)"></Icon>
            <div>建筑内用电量</div>
          </div>
          <div class="content">
            <div class="value">545466</div>
            <div class="unit">KW.H</div>
          </div>
        </div>
        <div class="info-item">
          <div class="title">
            <Icon name="map-filling" :size="30" color="rgba(255, 255, 255, 0.4)"></Icon>
            <div>建筑内电表数</div>
          </div>
          <div class="content">
            <div class="value">1234</div>
            <div class="unit">个</div>
          </div>
        </div>
        <div class="info-item">
          <div class="title">
            <Icon name="map-filling" :size="30" color="rgba(255, 255, 255, 0.4)"></Icon>
            <div>建筑内用水量</div>
          </div>
          <div class="content">
            <div class="value">1234</div>
            <div class="unit">个</div>
          </div>
        </div>
      </div>
    </Panel>
    <Panel title="能耗分析" width="380px">
      <div class="chart-container">
        <div style="height: 100%; width: 100%" ref="chartRef"></div>
      </div>
    </Panel>
    <Panel title="设备列表" width="380px">
      <DeviceTable :data="deviceList"></DeviceTable>
    </Panel>
  </div>
</template>

<script lang="ts" setup>
import * as echarts from "echarts";
import DeviceTable from "../DevicePanel/DeviceTable.vue";

const deviceList = ref([
  { id: "1", img: "img", name: "消防栓A", code: "A001", area: "1楼a区", status: "正常" },
  { id: "2", img: "img", name: "消防栓A", code: "A002", area: "1楼b区", status: "正常" },
  { id: "3", img: "img", name: "消防栓A", code: "A003", area: "1楼c区", status: "报警" },
  { id: "4", img: "img", name: "消防栓A", code: "A004", area: "1楼d区", status: "离线" },
  { id: "5", img: "img", name: "消防栓A", code: "A005", area: "1楼e区", status: "离线" },
]);
const chartRef = ref();
onMounted(() => {
  echarts.init(chartRef.value).setOption({
    tooltip: {
      trigger: "item",
    },
    legend: {
      icon: "circle",
      right: 30,
      top: "20%",
      orient: "vertical",
      textStyle: {
        color: "#FFFFFF",
      },
    },
    series: [
      {
        name: "能耗分析",
        type: "pie",
        radius: ["40%", "80%"],
        center: ["25%", "50%"],
        avoidLabelOverlap: false,
        itemStyle: {
          borderRadius: 10,
        },
        label: {
          show: false,
          position: "center",
        },
        emphasis: {
          label: {
            show: true,
            fontSize: 20,
            fontWeight: "bold",
          },
        },
        labelLine: {
          show: false,
        },
        data: [
          { value: 1048, name: "机房" },
          { value: 735, name: "空调" },
          { value: 580, name: "照明" },
          { value: 484, name: "工位" },
        ],
      },
    ],
  });
});
</script>
<style lang="scss" scoped>
.info {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  color: #fff;
  gap: 16px;
  font-size: 16px;
  font-family: YouSheBiaoTiHei;
  margin: 16px 0px;
  .info-item {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-left: 16px;
    border-left: 1px solid rgba(255, 255, 255, 0.4);
    width: 46%;
    .title,
    .content {
      display: flex;
      flex-direction: row;
      align-items: center;
    }
    .title {
      gap: 8px;
    }
    .content {
      justify-content: space-between;
    }
    .value {
      color: #41dbfd;
      background: rgba(255, 255, 255, 0.05);
      text-align: right;
      padding: 4px 8px;
      min-width: 80%;
    }
  }
}
.chart-container {
  width: 100%;
  height: 200px;
  padding: 16px 0px;
}
</style>
